<script setup lang="ts">
import { SET_ISAUTHENTICATED } from '@store/constant';
import { useRouter, useRoute } from 'vue-router';
import { useStore } from 'vuex';

const router = useRouter()

const route = useRoute()

const store = useStore()

function login() {
  console.log('登陆验证中...')
  setTimeout(() => {
    store.commit(SET_ISAUTHENTICATED, 'Im a token')
    const redirectUrl = route.query.redirectUrl ? decodeURIComponent(route.query.redirectUrl as string) : '/home'
    router.push(redirectUrl)
  }, 500)
}

function register() {
  router.push('/register')
}
</script>
  
<template>
  <h3>我是登陆页面</h3>
  <div>
    <button type="button" @click="login">登陆</button>&nbsp;
    <button type="button" @click="register">注册</button>
  </div>
</template>
  
<style scoped>
</style>
  